home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_3a.arc / DISPLAY.CLS < prev    next >
Text File  |  1989-02-21  |  3KB  |  110 lines

  1. // display.cls    a C++ Display class for placing data on the display.
  2. //
  3. // (c) Aspen Scientific 1989. All Rights Reserved.
  4. // Author: Vaughn Vernon
  5.  
  6. #ifndef _DISPLAY_CLASS
  7.  
  8. # define _DISPLAY_CLASS_     1
  9.  
  10. # include "mouse.cls"
  11. # include "point.cls"
  12. # include "rect.cls"
  13.  
  14.  
  15. // DisplayAttr class
  16.  
  17. typedef unsigned int    Attribute;
  18.  
  19. class DisplayAttr {
  20.  
  21. protected:
  22.     Attribute    attribute;
  23. public:
  24.     // set like this:
  25.     //
  26.     // DisplayAttr attr;
  27.     //
  28.     // attr.set(attr.backGreen() | attr.foreBlack());
  29.  
  30.     Attribute    set(Attribute a) { return attribute = a; }
  31.     Attribute    get()        { return attribute; }
  32.  
  33.     // generic/monochrome attributes
  34.     Attribute    blink()        { return 0x8000; }
  35.     Attribute    bold()        { return 0x0800; }
  36.     Attribute    normal()    { return 0x0700; }
  37.     Attribute    reverse()    { return 0x7000; }
  38.     Attribute    underline()    { return 0x0100; }
  39.  
  40.     // color attributes
  41.     Attribute    foreBlack()    { return 0x0000; }
  42.     Attribute    foreBlue()    { return 0x0100; }
  43.     Attribute    foreGreen()    { return 0x0200; }
  44.     Attribute    foreCyan()    { return 0x0300; }
  45.     Attribute    foreRed()    { return 0x0400; }
  46.     Attribute    foreMagenta()    { return 0x0500; }
  47.     Attribute    foreBrown()    { return 0x0600; }
  48.     Attribute    foreWhite()    { return 0x0700; }
  49.     Attribute    foreGray()    { return 0x0800; }
  50.     Attribute    foreLtBlue()    { return 0x0900; }
  51.     Attribute    foreLtGreen()    { return 0x0a00; }
  52.     Attribute    foreLtCyan()    { return 0x0b00; }
  53.     Attribute    foreLtRed()    { return 0x0c00; }
  54.     Attribute    foreLtMagenta()    { return 0x0d00; }
  55.     Attribute    foreYellow()    { return 0x0e00; }
  56.     Attribute    foreBrightWhite() { return 0x0f00; }
  57.  
  58.     Attribute    backBlack()    { return 0x0000; }
  59.     Attribute    backBlue()    { return 0x1000; }
  60.     Attribute    backGreen()    { return 0x2000; }
  61.     Attribute    backCyan()    { return 0x3000; }
  62.     Attribute    backRed()    { return 0x4000; }
  63.     Attribute    backMagenta()    { return 0x5000; }
  64.     Attribute    backBrown()    { return 0x6000; }
  65.     Attribute    backWhite()    { return 0x7000; }
  66.  
  67.     DisplayAttr() { attribute = normal(); }
  68.     ~DisplayAttr() { }
  69. };
  70.  
  71. // Display class
  72.  
  73. class Display : public Rectangle {
  74.  
  75. protected:
  76.     Point        cursor;
  77.     Mouse    *    mouse;
  78.     DisplayAttr    defAttr;
  79.     unsigned    color;
  80.     unsigned    snow;
  81.     static unsigned videoSeg;
  82.     static char    init;
  83. public:
  84.     Display(const Mouse *);
  85.     ~Display();
  86.  
  87.     virtual void    clear();
  88.     void        operator()(unsigned, unsigned);
  89.     void        operator()(Point & p) { cursor = p; }
  90.     Point &        operator()() { return cursor; }
  91.     void        cursorOff();
  92.     void        cursorOn();
  93.     unsigned    hasColor()    { return color; }
  94.     void        defaultAttr(DisplayAttr & a) { defAttr = a; }
  95.     virtual void    putString(Point &, const unsigned char *,
  96.                 DisplayAttr &);
  97.     virtual void    putChar(Point &, unsigned char, DisplayAttr &);
  98.     Display &    operator<<(const unsigned char * s) {
  99.             putString(cursor, s, defAttr);
  100.             return *this;
  101.     }
  102.     Display &    operator<<(unsigned char c) {
  103.             putChar(cursor, c, defAttr);
  104.             return *this;
  105.     }
  106.     virtual void    draw();
  107. };
  108.  
  109. #endif // __DISPLAY_CLASS__
  110.